<style type="text/css">
.ui-jqgrid-sortable {
	text-align: center;
}
</style>

<div id="court_container">
	<div class="row">
		<div class="col-xs-12">

			<table id="court_grid-table"></table>

			<div id="court_grid-pager"></div>

		</div>
		<!-- /.col -->
	</div>
	<!-- /.row -->


	<div id="courtModalDiv" class="modal fade" tabindex="-1"
		data-backdrop="static">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header no-padding">
					<div class="table-header">
						<button type="button" class="close" data-dismiss="modal"
							aria-hidden="true">
							<span class="white">&times;</span>
						</button>
						<span>添加小区</span>
					</div>
				</div>
				<div class="modal-body"
					style="max-height: 450px; overflow-y: scroll;">
					<div id="modal-tip" class="red clearfix"></div>
					<form id="courtForm" name="courtForm"
						class="form-horizontal  col-xs-12">
						<div class="widget-box  ui-sortable-handle">
							<div class="widget-header">
								<h4 class="widget-title">基本信息</h4>
							</div>
							<div class="widget-body">
								<input type="hidden" name="id" id="id" /> <input type="hidden"
									name="files" id="courtfiles" /> <input type="hidden"
									name="parentId" id="parentId" />
								<div class="widget-main">
									<div class="row" style="padding-bottom: 2px">
										<div class="form-group">
											<label class="col-sm-3 control-label">小区名称</label>
											<div class="col-sm-9">
												<input type="text" class="form-control" id="name"
													name="name" />
											</div>
										</div>
									</div>
									<div class="row" style="padding-bottom: 2px">
										<div class="form-group">
											<label class="col-sm-3 control-label">总户数</label>
											<div class="col-sm-9">
												<input type="text" class="form-control" id="courtcount"
													name="courtcount" />
											</div>
										</div>
									</div>
									<div class="row" style="padding-bottom: 2px">
										<div class="form-group">
											<label class="col-sm-3 control-label">纬度坐标</label>
											<div class="col-sm-9">
												<input type="text" class="form-control" id="lat" name="lat" />
											</div>
										</div>
									</div>
									<div class="row" style="padding-bottom: 2px">
										<div class="form-group">
											<label class="col-sm-3 control-label">经度坐标</label>
											<div class="col-sm-9">
												<input type="text" class="form-control" id="lng" name="lng" />
											</div>
										</div>
									</div>
									<div class="row" style="padding-bottom: 2px">
										<div class="form-group">
											<label class="col-sm-3 control-label">详细地址</label>
											<div class="col-sm-9">
												<input type="text" class="form-control" id="address"
													name="address" />
											</div>
										</div>
									</div>

									<div class="row" style="padding-bottom: 2px">
										<div class="form-group">
											<label class="col-sm-3 control-label">联系人</label>
											<div class="col-sm-9">
												<input type="text" class="form-control" id="linkman"
													name="linkman" />
											</div>
										</div>
									</div>

									<div class="row" style="padding-bottom: 2px">
										<div class="form-group">
											<label class="col-sm-3 control-label">联系电话</label>
											<div class="col-sm-9">
												<input type="text" class="form-control" id="phoneno"
													name="phoneno" />
											</div>
										</div>
									</div>
								</div>
							</div>
						</div>
						<div class="row" style="padding-bottom: 2px;">
							<div class="col-xs-12">
								<div class="widget-box  ui-sortable-handle">
									<div class="widget-header">
										<h4 class="widget-title">图片信息</h4>
										<div class="widget-toolbar">
											<a href="#" title="添加图片" data-action="settings"> <i
												class="1 ace-icon fa bigger-125  fa-cloud-upload fileinput-button" id="addCourtButton"></i>
											</a>
										</div>
									</div>
									<div class="widget-body">
										<div class="widget-main">
											<div class="dropzone" id="courtdropzone"></div>
										</div>
									</div>
								</div>
							</div>
						</div>
					</form>
				</div>
				<div class="modal-footer no-margin-top">
					<div class="text-center">

						<button id="submitCourtBtn" class="btn btn-sm btn-primary">
							<i class="ace-icon fa fa-floppy-o"></i> <span>保存</span>
						</button>

						<button class="btn btn-sm" data-dismiss="modal">
							<i class="ace-icon fa fa-share "></i> <span>取消</span>
						</button>
					</div>
				</div>
			</div>
		</div>
		<!-- /.modal-content -->

		<div id="courtpreview-template" style="display: none">
			<div class="dz-preview dz-file-preview">
				<div class="dz-details">
					<div class="dz-filename">
						<span data-dz-name></span>
					</div>
					<div class="dz-size" data-dz-size></div>
					<a id='' href='#' class="image-see" data-rel='colorbox'><img
						data-dz-thumbnail /> </a>
				</div>
				<div class="dz-progress">
					<span class="dz-upload" data-dz-uploadprogress></span>
				</div>
				<div class="dz-success-mark">
					<span>✔</span>
				</div>
				<div class="dz-error-mark">
					<span>✘</span>
				</div>
				<div class="dz-error-message">
					<span data-dz-errormessage></span>
				</div>
				<div class="center">
					<span data-dz-remove> <a href="#" data-action="delete"
						class="middle"> <i
							class="ace-icon fa fa-trash-o red bigger-130 middle"></i>
					</a>
					</span>
				</div>
			</div>
		</div>
	</div>
	
	<div id="doorplateGridDiv" class="modal fade" tabindex="-1"
		data-backdrop="static">
		<div class="modal-dialog" style="width:700px;">
			<div class="modal-content">
				<div class="modal-header no-padding">
					<div class="table-header">
						<button type="button" class="close" data-dismiss="modal"
							aria-hidden="true">
							<span class="white">&times;</span>
						</button>
						<span>管理门牌号</span>
					</div>
				</div>
				<div class="modal-body" style="max-height: 600px; overflow-y: scroll;">
					<div class="row">
						<div class="col-xs-12">
							<table id="doorplate_grid-table"></table>
							<div id="doorplate_grid-pager"></div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>

	<div id="ywhVoteTaskDiv" class="modal fade" tabindex="-1"
		data-backdrop="static">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header no-padding">
					<div class="table-header">
						<button type="button" class="close" data-dismiss="modal"
							aria-hidden="true">
							<span class="white">&times;</span>
						</button>
						<span>业委会选举任务管理</span>
					</div>
				</div>
				<div class="modal-body"
					style="max-height: 450px; overflow-y: scroll;">
					<div id="doorplatemodal-tip" class="red clearfix"></div>
					<div class="widget-box  ui-sortable-handle">
						<div class="widget-header">
							<h4 class="widget-title">选举任务开启关闭</h4>
						</div>
						<div class="widget-body">
							<input type="hidden" name="courtId" id="ywh_vote_task_court_id" />
							<input type="hidden" name="isActive" id="ywh_vote_task_is_active" />
							<input type="hidden" name="taskCode" id="ywh_vote_task_code" />
							<input type="hidden" name="taskName" id="ywh_vote_task_name" />
							<div class="widget-main">
								<div class="row" style="padding-bottom: 2px">
									<div class="form-group">
										<label class="col-sm-3 control-label">任务状态</label>
										<div class="col-sm-9">
											<div id="ywh_vote_task_container">
											</div>
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
				<div class="modal-footer no-margin-top">
					<div class="text-center">

						<button id="ywhRwBtn" class="btn btn-sm btn-primary">
							<i class="ace-icon fa fa-floppy-o"></i> <span id="ywhRwBtnTitle"></span>
						</button>

						<button class="btn btn-sm" data-dismiss="modal">
							<i class="ace-icon fa fa-share "></i> <span>取消</span>
						</button>
					</div>
				</div>
			</div>
		</div>
	</div>

	<div id="ywhSettingsGridDiv" class="modal fade" tabindex="-1" data-backdrop="static">
		<div class="modal-dialog">
			<div class="modal-content" id="ywh-settings-modal-content">
				<div class="modal-header no-padding">
					<div class="table-header">
						<button type="button" class="close" data-dismiss="modal"
							aria-hidden="true">
							<span class="white">&times;</span>
						</button>
						<span>业委会成员数量设置</span>
					</div>
				</div>
				<div class="modal-body" style="max-height: 620px; min-width: 265px; overflow-y: scroll;">
			        <!-- #section:pages/inbox -->
	                <div class="tabbable">
					    <ul class="nav nav-tabs padding-12 tab-color-blue background-blue" id="ywh-settings-tabs">
					        <li class="active">
					            <a data-toggle="tab" href="#wy-count-content">委员人数</a>
					        </li>
					        <li>
					            <a data-toggle="tab" href="#ld-count-content">楼栋及单元人数</a>
					        </li>
					    </ul>
					    <div class="tab-content">
					        <div id="wy-count-content" class="tab-pane in active">
					            <form id="ywhSettingsWyForm" name="ywhSettingsWyForm"
									class="form-horizontal  col-xs-12"> 
									<div class="widget-box  ui-sortable-handle">
										<div class="widget-header">
											<h4 class="widget-title">委员人数设置</h4>
										</div>
										<div class="widget-body">
											<input type="hidden" name="id" id="ywh_settings_wy_court_id" />
											<div class="widget-main">
												<div class="row" style="padding-bottom: 2px">
													<div class="form-group">
														<label class="col-sm-3 control-label">小区名称</label>
														<div class="col-sm-9">
															<input type="text" class="form-control" disabled readonly="true" id="ywhSettings_name"
																name="name" />
														</div>
													</div>
												</div>
												<div class="row" style="padding-bottom: 2px">
													<div class="form-group">
														<label class="col-sm-3 control-label">总户数</label>
														<div class="col-sm-9">
															<input type="text" class="form-control" disabled readonly="true" id="ywh_settings_courtcount"
																name="courtcount" />
														</div>
													</div>
												</div>
												<div class="row" style="padding-bottom: 2px">
													<div class="form-group">
														<label class="col-sm-3 control-label">委员数</label>
														<div class="col-sm-9">
															<input type="text" class="form-control" id="ywh_settings_wyCount"
																name="wyCount" />
														</div>
													</div>
												</div>
											</div>
										</div>
									</div>
								</form>
								<div class="modal-footer no-margin-top">
									<div class="text-center">
				
										<button id="submitYwhWySettings" class="btn btn-sm btn-primary">
											<i class="ace-icon fa fa-floppy-o"></i> <span>保存</span>
										</button>
				
										<button class="btn btn-sm" data-dismiss="modal">
											<i class="ace-icon fa fa-share "></i> <span>取消</span>
										</button>
									</div>
								</div>
					        </div>
					        <div id="ld-count-content" class="tab-pane">
								<div class="row">
									<div class="col-xs-12">
										<table id="ywh_settings_grid_table"></table>
										<div id="ywh_settings_grid_pager"></div>
									</div>
								</div>
					        </div>
					    </div>
					</div>
				</div>
			</div>
		</div>
	</div>

	<div id="ywhSettingsModalDiv" class="modal fade" tabindex="-1"
		data-backdrop="static">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header no-padding">
					<div class="table-header">
						<button type="button" class="close" data-dismiss="modal"
							aria-hidden="true">
							<span class="white">&times;</span>
						</button>
						<span>设置业务会成员数</span>
					</div>
				</div>
				<div class="modal-body"
					style="max-height: 450px; overflow-y: scroll;">
					<div id="doorplatemodal-tip" class="red clearfix"></div>
					<form id="ywhSettingsForm" name="ywhSettingsForm"
						class="form-horizontal  col-xs-12">
						<div class="widget-box  ui-sortable-handle">
							<div class="widget-header">
								<h4 class="widget-title">基本信息</h4>
							</div>
							<div class="widget-body">
								<input type="hidden" name="courtId" id="ywh_settings_court_id" />
								<input type="hidden" name="id" id="ywh_settings_id" /> 
								<div class="widget-main">
									<div class="row" style="padding-bottom: 2px">
										<div class="form-group">
											<label class="col-sm-3 control-label">楼栋号</label>
											<div class="col-sm-9">
												<input type="text" class="form-control" disabled readonly="true" id="ywh_settings_building"
													name="building" />
											</div>
										</div>
									</div>
									<div class="row" style="padding-bottom: 2px">
										<div class="form-group">
											<label class="col-sm-3 control-label">单元号</label>
											<div class="col-sm-9">
												<input type="text" class="form-control" disabled readonly="true" id="ywh_settings_unit"
													name="unit" />
											</div>
										</div>
									</div>
									<div class="row" style="padding-bottom: 2px">
										<div class="form-group">
											<label class="col-sm-3 control-label">总户数</label>
											<div class="col-sm-9">
												<input type="text" class="form-control" disabled readonly="true" id="ywh_settings_total_doors"
													name="totalDoors" />
											</div>
										</div>
									</div>
									<div class="row" style="padding-bottom: 2px">
										<div class="form-group">
											<label class="col-sm-3 control-label">业委会成员数</label>
											<div class="col-sm-9">
												<input type="text" class="form-control" id="ywh_settings_count_member"
													name="countMember" />
											</div>
										</div>
									</div>
								</div>
							</div>
						</div>
					</form>
				</div>
				<div class="modal-footer no-margin-top">
					<div class="text-center">

						<button id="ywhSettingsBtn" class="btn btn-sm btn-primary">
							<i class="ace-icon fa fa-floppy-o"></i> <span>保存</span>
						</button>

						<button class="btn btn-sm" data-dismiss="modal">
							<i class="ace-icon fa fa-share "></i> <span>取消</span>
						</button>
					</div>
				</div>
			</div>
		</div>
	</div>

	<div id="doorplateModalDiv" class="modal fade" tabindex="-1"
		data-backdrop="static">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header no-padding">
					<div class="table-header">
						<button type="button" class="close" data-dismiss="modal"
							aria-hidden="true">
							<span class="white">&times;</span>
						</button>
						<span>添加门牌号</span>
					</div>
				</div>
				<div class="modal-body"
					style="max-height: 450px; overflow-y: scroll;">
					<div id="doorplatemodal-tip" class="red clearfix"></div>
					<form id="doorplateForm" name="doorplateForm"
						class="form-horizontal  col-xs-12">
						<div class="widget-box  ui-sortable-handle">
							<div class="widget-header">
								<h4 class="widget-title">基本信息</h4>
							</div>
							<div class="widget-body">
								<input type="hidden" name="courtId" id="courtId" />
								<input type="hidden" name="id" id="doorplateId" /> 
								<div class="widget-main">
									<div class="row" style="padding-bottom: 2px">
										<div class="form-group">
											<label class="col-sm-3 control-label">楼栋号</label>
											<div class="col-sm-9">
												<input type="text" class="form-control" id="doorplateBuilding"
													name="building" />
											</div>
										</div>
									</div>
									<div class="row" style="padding-bottom: 2px">
										<div class="form-group">
											<label class="col-sm-3 control-label">单元号</label>
											<div class="col-sm-9">
												<input type="text" class="form-control" id="doorplateUnit"
													name="unit" />
											</div>
										</div>
									</div>
									<div class="row" style="padding-bottom: 2px">
										<div class="form-group">
											<label class="col-sm-3 control-label">楼层号</label>
											<div class="col-sm-9">
												<input type="text" class="form-control" id="floor"
													name="floor" />
											</div>
										</div>
									</div>
									<div class="row" style="padding-bottom: 2px">
										<div class="form-group">
											<label class="col-sm-3 control-label">房号</label>
											<div class="col-sm-9">
												<input type="text" class="form-control" id="doorNo"
													name="doorNo" />
											</div>
										</div>
									</div>
									<div class="row" style="padding-bottom: 2px">
										<div class="form-group">
											<label class="col-sm-3 control-label">门牌号</label>
											<div class="col-sm-9">
												<input type="text" class="form-control" id="doorplateNo"
													name="doorplateNo" />
											</div>
										</div>
									</div>
								</div>
							</div>
						</div>
					</form>
				</div>
				<div class="modal-footer no-margin-top">
					<div class="text-center">

						<button id="submitDoorplateBtn" class="btn btn-sm btn-primary">
							<i class="ace-icon fa fa-floppy-o"></i> <span>保存</span>
						</button>

						<button class="btn btn-sm" data-dismiss="modal">
							<i class="ace-icon fa fa-share "></i> <span>取消</span>
						</button>
					</div>
				</div>
			</div>
		</div>
	</div>
	
	<div id="doorplateExcelModalDiv" class="modal fade" tabindex="-1"
		data-backdrop="static">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header no-padding">
					<div class="table-header">
						<button type="button" class="close" data-dismiss="modal"
							aria-hidden="true">
							<span class="white">&times;</span>
						</button>
						<span>导入Excel</span>
					</div>
				</div>
				<div class="modal-body"
					style="max-height: 450px; overflow-y: scroll;">
					<div id="doorplateExcelmodal-tip" class="red clearfix"></div>
					<div class="row" style="padding-bottom: 2px;">
						<div class="col-xs-12">
							<div class="widget-box  ui-sortable-handle">
								<div class="widget-header">
									<input type="hidden" name="courtId" id="courtIdForDoor" />
									<input type="hidden" id="filePathForDoor" />
									<input type="hidden" id="fileIdForDoor" />
									<input type="hidden" id="fileSuffixForDoor" />
									<h4 class="widget-title">上传数据文件（只支持Excel）</h4>
									<div class="widget-toolbar">
										<a href="#" title="选择文件" data-action="settings"> <i
											class="1 ace-icon fa bigger-125  fa-cloud-upload fileinput-button red" id="excelButton"></i>
										</a>
									</div>
								</div>
								<div class="widget-body">
									<div class="widget-main">
										<div class="dropzone" id="doorplateExceldropzone"></div>
									</div>
								</div>
							</div>
						</div>
					</div>  
				</div>
				<div class="modal-footer no-margin-top">
					<div class="text-center">

						<button id="excelImportBtn" class="btn btn-sm btn-primary">
							<i class="ace-icon fa fa-floppy-o"></i> <span>导入</span>
						</button>

						<button class="btn btn-sm" data-dismiss="modal">
							<i class="ace-icon fa fa-share "></i> <span>取消</span>
						</button>
					</div>
				</div>
			</div>
		</div>
	</div>
	<!-- /.modal-dialog -->
</div>

<script type="text/javascript">
	var courtScripts = [ null, "component/assets/js/dropzone.js",
			"component/assets/js/jquery.colorbox.js", null ];
	var $courtContainer = $('#court_container');
	var courtGrid = null;
	var doorplateGrid =null;
	var ywhSettingsGrid = null;
	var ywhVoteTaskGrid = null;
	var $validateCourtForm = null;
	var $validateDoorplateForm = null;
	var $ywhSettingsWyForm = null;
	var excelDropzone=null;
	var courtDropzone=null;
	var courtMuban=null;

	var colorbox_params = {
		rel : 'colorbox',
		reposition : true,
		scalePhotos : true,
		scrolling : false,
		previous : '<i class="ace-icon fa fa-arrow-left"></i>',
		next : '<i class="ace-icon fa fa-arrow-right"></i>',
		close : '&times;',
		current : '{current} of {total}',
		maxWidth : '100%',
		maxHeight : '90%',
		onOpen : function() {
			$overflow = document.body.style.overflow;
			document.body.style.overflow = 'hidden';
		},
		onClosed : function() {
			document.body.style.overflow = $overflow;
		},
		onComplete : function() {
			$.colorbox.resize();
		}
	};

	$('.page-content-area')
			.ace_ajax(
					'loadScripts',
					courtScripts,
					function() {
						var grid_selector = "#court_grid-table";
						var pager_selector = "#court_grid-pager";

						var colNames = [ '', '名称','总户数', '所在纬度', '所在经度', '详细地址',
								'联系人', '联系电话', '操作' ];
						createCourtGrid();

						$validateCourtForm = $('#courtForm', $courtContainer)
								.validate({
									onsubmit : false,
									rules : {
										name : {
											required : true,
											maxlength : 75
										},
										courtcount : {
											required : true,
											digits : true
										},
										lat : {
											required : true,
											number : true 
										},
										lng : {
											required : true,
											number : true
										},
										address : {
											required : true,
											maxlength : 115
										}
									}
								});
						
						$validateDoorplateForm = $('#doorplateForm').validate({
							onsubmit : false,
							rules : {
								doorplateNo : {
									required : true,
									maxlength: 35
								},
								unit : {
									required : true,
									maxlength: 35
								},
								building : {
									required : true,
									maxlength: 35
								}
							}
						});

						$ywhSettingsWyForm = $('#ywhSettingsWyForm', $courtContainer)
								.validate({
									onsubmit : false,
									rules : {
										wyCount : {
											required : true,
											digits: true,
											min: 3,
											max: 13
										}
									}
								});

						$('#submitYwhWySettings').click(function() {
							if (!$ywhSettingsWyForm.checkForm()) {
								$ywhSettingsWyForm.defaultShowErrors();
								return;
							}
							var url = $(this).attr("url");
							$.loy.confirm("确定要修改委员个数？", function() {
								$.loy.ajax({
									url : url,
									data : {
										courtId: $("#ywh_settings_wy_court_id").val(),
										wyCount: $("#ywh_settings_wyCount").val()
									},
									success : function(data) {
										if (data.data) {
											alert("修改成功！");
										} else {
											alert("修改失败！");
										}
									},
									error : function(data) {
										alert("发生错误");
									}
								});
							});
						});

						$('#submitCourtBtn').click(function() {
							if (!$validateCourtForm.checkForm()) {
								$validateCourtForm.defaultShowErrors();
								return;
							}
							var url = $(this).attr("url");
							var fileIds = [];
							var id = $('#id',$("#courtForm", $courtContainer)).val();
							$('.dropzone [data-rel="colorbox"]').map(
									function(k, v) {
										fileIds.push(v.id);
									})
							$("#courtfiles", $courtContainer).val(fileIds);
							var message = "";
							if (id && id != "") {
								message = "确定要修改这条记录吗？"
							} else {
								message = "确定要添加一条记录吗？"
							}
							$.loy.confirm(message, function() {
								$.loy.ajax({
									url : url,
									data : $("#courtForm",
											$courtContainer)
											.serialize(),
									success : function(data) {
										$('#courtModalDiv',
												$courtContainer).modal(
												"hide");
										courtGrid.jqGrid().trigger(
												"reloadGrid");
									},
									error : function(data) {
										alert("发生错误");
									}
								});
							});
						});
						
						$('#submitDoorplateBtn').click(
							function() {
								if (!$validateDoorplateForm.checkForm()) {
									$validateDoorplateForm.defaultShowErrors();
									return;
								}
								var url = $(this).attr("url");
								var message = "确定要添加门牌号到这个小区吗？";
								$.loy.confirm(message, function() {
									$.loy.ajax({
										url : url,
										data : $("#doorplateForm").serialize(),
										success : function(data) {
											$('#doorplateModalDiv',$courtContainer).modal("hide");
											doorplateGrid.jqGrid().trigger("reloadGrid");
										},
										error : function(data) {
											alert("发生错误");
										}
									});
								});
							});
						
						$("#excelImportBtn").on("click",function(){
							var filepath=$("#filePathForDoor").val();
							if(filepath==""||null==filepath){
								$.loy.alert("请先上传文件！");
								return;
							}
							let t = this;
							//上传完成后触发的方法
							$.loy.confirm("确定要进行导入吗？这可能导致原数据被覆盖！", function() {
								$.loy.ajax({
									url : "/excel/import/door",
									timeout: 1000 * 60 * 5,
									data : {
										"filePath" : $("#filePathForDoor").val(),
										"fileSuffix" : $("#fileSuffixForDoor").val(),
										"courtId" : $("#courtIdForDoor").val(),
										"fileId" : $("#fileIdForDoor").val()
									},
									success : function(data) {
										console.log(data);
										if(data.data.error === 0){
											$.loy.alert(data.data.successMsg);
											$('#doorplateExcelModalDiv',$courtContainer).modal("hide");
											refreshGrid();
										}else{
											$.loy.alert(data.data.errorMsg);
										}
									},
									error : function(data) {
										alert("发生错误");
									}
								});
							});
						})

						function createCourtGrid() {
							courtGrid = jQuery(grid_selector)
									.loyGrid(
											{
												url : 'xq/findAllPage',
												datatype : "json",
												mtype : 'GET',
												colNames : colNames,
												colModel : [
														{
															name : 'id',
															index : 'id',
															sortable : false,
															width : 100,
															align : "center",
															editable : true,
															hidden : true
														},
														{
															name : 'name',
															index : 'name',
															sortable : false,
															width : 100,
															align : "center",
															editable : true
														},
														{
															name : 'courtcount',
															index : 'courtcount',
															sortable : false,
															width : 50,
															align : "center",
															editable : true
														},
														{
															name : 'lat',
															index : 'lat',
															sortable : false,
															width : 50,
															align : "center",
															editable : true
														},
														{
															name : 'lng',
															index : 'lng',
															sortable : false,
															width : 50,
															align : "center",
															editable : true
														},
														{
															name : 'address',
															index : 'address',
															sortable : false,
															width : 200,
															align : "center",
															editable : true
														},
														{
															name : 'linkman',
															index : 'linkman',
															sortable : false,
															width : 50,
															align : "center",
															editable : true
														},
														{
															name : 'phoneno',
															index : 'phoneno',
															sortable : false,
															width : 50,
															align : "center",
															editable : true
														},
														{
															name : '',
															index : '',
															width : 200,
															fixed : true,
															sortable : false,
															resize : false,
															align : "center",
															formatter : function(
																	cellvalue,
																	options,
																	rowObject) {
																var button = '';
																if (hasPermissionByCode('resource:update')) {
																	button += '<div title="'
																			+ $.jgrid.nav.edittitle
																			+ '" onclick=courtEdit("'
																			+ rowObject.id
																			+ '");  style="float:left;margin-left:20px;" class="ui-pg-div ui-inline-del"  onmouseover="jQuery(this).addClass(\'ui-state-hover\');" onmouseout="jQuery(this).removeClass(\'ui-state-hover\');"  data-original-title="所选记录"><span class="ui-icon ui-icon-pencil"></span></div>';
																}
																if (hasPermissionByCode('resource:del')) {
																	var del = '<div title="'
																			+ $.jgrid.nav.deltitle
																			+ '" onclick=courtDel("'
																			+ rowObject.id
																			+ '");  style="float:left;margin-left:5px;" class="ui-pg-div ui-inline-del"  onmouseover="jQuery(this).addClass(\'ui-state-hover\');" onmouseout="jQuery(this).removeClass(\'ui-state-hover\');"  data-original-title="所选记录"><span class="ui-icon ace-icon ace-icon fa fa-trash-o red"></span></div>';
																	button += del;
																}
																var addDoorplate= '<div title="'
																	+ "管理门牌号"
																	+ '" onclick=doorplateWatch("'
																	+ rowObject.id
																	+ '");  style="float:left;margin-left:5px;" class="ui-pg-div ui-inline-del"  onmouseover="jQuery(this).addClass(\'ui-state-hover\');" onmouseout="jQuery(this).removeClass(\'ui-state-hover\');"  data-original-title="所选记录"><span class="ui-icon ace-icon fa fa-key green"></span></div>';
																	button += addDoorplate;
																var importDoorplate= '<div title="'
																	+ "小区数据导入"
																	+ '" onclick=doorplateImport("'
																	+ rowObject.id
																	+ '");  style="float:left;margin-left:5px;" class="ui-pg-div ui-inline-del"  onmouseover="jQuery(this).addClass(\'ui-state-hover\');" onmouseout="jQuery(this).removeClass(\'ui-state-hover\');"  data-original-title="所选记录"><span class="ui-icon ace-icon fa fa-cloud-upload red"></span></div>';
																	button += importDoorplate;
																var ywhSettings= '<div title="'
																	+ "业委会成员设置"
																	+ '" onclick=ywhSettings("'
																	+ rowObject.id
																	+ '","'
																	+ rowObject.name
																	+ '","'
																	+ rowObject.courtcount
																	+ '","'
																	+ rowObject.wyCount
																	+ '");  style="float:left;margin-left:5px;" class="ui-pg-div ui-inline-del"  onmouseover="jQuery(this).addClass(\'ui-state-hover\');" onmouseout="jQuery(this).removeClass(\'ui-state-hover\');"  data-original-title="所选记录"><span class="ui-icon ace-icon fa fa-cog yellow"></span></div>';
																	button += ywhSettings;
																// 业委会投票任务
																var ywhVoteTask = '<div title="'
																	+ "业委会投票任务"
																	+ '" onclick=ywhVoteTask("'
																	+ rowObject.id
																	+ '");  style="float:left;margin-left:5px;" class="ui-pg-div ui-inline-del"  onmouseover="jQuery(this).addClass(\'ui-state-hover\');" onmouseout="jQuery(this).removeClass(\'ui-state-hover\');"  data-original-title="所选记录"><span class="ui-icon ace-icon fa fa-bolt red"></span></div>';
																	button += ywhVoteTask;
																return button;
															}
														} ],
												pager : pager_selector,
												width : $(".page-content")
														.width(),
												height : getGridDefaultHeight(),
											}).loyGrid('navGrid',
											'#court_grid-pager', {
												"baseUrl" : "xq/",
												accessCodePrefix : 'addxqInfo',
												"addfunc" : function() {
													courtAdd('');
												},
												"excelfunc" : function(){
													$("#courtIdForDoor").val("");
													if(excelDropzone!=null){
														excelDropzone.destroy();
														$("#filePathForDoor").val("");
														$("#fileIdForDoor").val("");
														$("#fileSuffixForDoor").val("");
													}
													initExcelDropZone();
													$("#doorplateExcelModalDiv", $courtContainer).modal("show");
												},
												view : false,
												add : true,
												edit : false,
												del : false,
												excel : true,
												exceltitle: "导入小区数据",
											});
							courtGrid.jqGrid('setFrozenColumns');
						}

					});
	function clearCourtForm() {
		$validateCourtForm.resetForm();
		$('#id', $courtContainer).val('');
		$('#name', $courtContainer).val('');
		$('#courtcount', $courtContainer).val('');
		$('#lat', $courtContainer).val('');
		$('#lng', $courtContainer).val('');
		$('#address', $courtContainer).val('');
		$('#linkman', $courtContainer).val('');
		$('#phoneno', $courtContainer).val('');
		$('.dz-preview').remove();
	}
	function clearDoorPlateForm() {
		$validateDoorplateForm.resetForm();
		$('#doorplateNo').val('');
		$('#doorplateUnit').val('');
		$('#doorplateBuilding').val('');
		$('#floor').val('');
		$('#doorNo').val('');
	}
	function courtEdit(id) {
		if(courtMuban==null){
			courtMuban=document.querySelector('#courtpreview-template').innerHTML;
		}
		if(courtDropzone!=null){
			courtDropzone.destroy();
		}
		initCourtDropZone(courtMuban);
		clearCourtForm();
		$('#submitCourtBtn', $courtContainer).attr("url", "xq/addxqInfo");
		$('#courtModalDiv', $courtContainer).modal("show");
		$.loy
				.ajax({
					url : 'xq/findOne',
					shade : false,
					data : {
						id : id
					},
					success : function(data) {
						var result = data.data;
						$('#id', $courtContainer).val(
								result.id ? result.id : '');
						$('#name', $courtContainer).val(
								result.name ? result.name : '');
						$('#courtcount', $courtContainer).val(
								result.courtcount ? result.courtcount : '');
						$('#lat', $courtContainer).val(
								result.lat ? result.lat : '');
						$('#lng', $courtContainer).val(
								result.lng ? result.lng : '');
						$('#address', $courtContainer).val(
								result.address ? result.address : '');
						$('#linkman', $courtContainer).val(
								result.linkman ? result.linkman : '');
						$('#phoneno', $courtContainer).val(
								result.phoneno ? result.phoneno : '');

						$.loy.ajax({
							url : "/sys/img/getFiles",
							showSuccess : false,
							type : 'GET',
							data : {
								aId : result.id
							},
							success : function(data) {
								$.each(data.data, function(index, item) {
									var mockFile = {
										id : item.id,
										name : item.medianame,
										size : item.mediasize,
										httpurl : item.httpurl
									};

									// Call the default addedfile event handler
									MDropzone.emit("addedfile", mockFile);
									// And optionally show the thumbnail of the file:
									MDropzone.emit("thumbnail", mockFile,
											item.httpurl);

								});

								$('.dropzone [data-rel="colorbox"]').colorbox(
										colorbox_params);
							}
						});
					}
				});
	}
	function courtAdd(parentId) {
		if(courtMuban==null){
			courtMuban=document.querySelector('#courtpreview-template').innerHTML;
		}
		courtMuban=document.querySelector('#courtpreview-template').innerHTML;
		if(courtDropzone!=null){
			courtDropzone.destroy();
		}
		initCourtDropZone(courtMuban);
		clearCourtForm();
		$('#parentId', $courtContainer).val(parentId);
		$('#submitCourtBtn', $courtContainer).attr("url", "xq/addxqInfo");
		$('#courtModalDiv', $courtContainer).modal("show");
	}
	function courtDel(id) {
		var that = this;
		$.loy.confirm($.i18n.prop('confirm_info_del'), function() {
			$.loy.ajax({
				url : 'xq/delxq',
				data : {
					id : id
				},
				success : function(data) {
					that.refreshGrid();
				}
			});
		});
	}
	function refreshGrid() {
		courtGrid.jqGrid().trigger("reloadGrid");
	}
	function refreshDoorplateGrid() {
		doorplateGrid.jqGrid().trigger("reloadGrid");
	}
	function doorplateAdd(xqid){
		clearDoorPlateForm();
		$('#courtId').val(xqid);
		$("#doorplateId").val('');
		$('#submitDoorplateBtn').attr("url", "mp/addmpInfo");
		$('#doorplateModalDiv', $courtContainer).modal("show");
	}
	function doorplateWatch(xqid){
		$('#doorplateGridDiv', $courtContainer).modal("show");
		createDoorplateGrid(xqid);
	}
	function doorplateImport(xqid) {
		$("#courtIdForDoor").val(xqid);
		if(excelDropzone!=null){
			excelDropzone.destroy();
			$("#filePathForDoor").val("");
			$("#fileIdForDoor").val("");
			$("#fileSuffixForDoor").val("");
		}
		initExcelDropZone();
		$("#doorplateExcelModalDiv", $courtContainer).modal("show");
	}
	function ywhVoteTask(xqid) {
		$("#ywh_vote_task_court_id").val(xqid);
		$("#ywhVoteTaskDiv", $courtContainer).modal("show");
		$.loy
		.ajax({
			url : 'rw/activeRenwu',
			shade : false,
			data : {
				courtId : xqid
			},
			success : function(response) {
				console.log(response);
				if (response.data) {
					const rw = response.data;
					$("#ywh_vote_task_is_active").val(rw.active);
					$("#ywh_vote_task_code").val(rw.code);
					$("#ywh_vote_task_name").val(rw.name);
					$("#ywh_vote_task_container").text(rw.name+'选举正在进行中');
					$("#ywhRwBtnTitle").text("停止任务")
				} else {
					$("#ywh_vote_task_is_active").val(false);
					$("#ywh_vote_task_container").text('选举未开始');
					$("#ywhRwBtnTitle").text("开始任务")
				}
			}
		});
		$('#ywhRwBtn').click(function() {
			const courtId = $("#ywh_vote_task_court_id").val();
			const active = $("#ywh_vote_task_is_active").val();
			const code = $("#ywh_vote_task_code").val();
			console.log(courtId, active, code);
			console.log(typeof active);
			if (active === 'true') {
				alert("无法停止任务");
			} else {
				$.loy.confirm("确定要开始选举任务吗？", function() {
					$.loy.ajax({
						url : "rw/open",
						method : "GET",
						shade : false,
						data : {
							courtId: courtId,
							rwCode: 'CAST01'
						},
						success : function(response) {
							console.log(response);
							if (response.data) {
								alert("启动任务成功");
								$('#ywhVoteTaskDiv', $courtContainer).modal("hide");
							} else {
								alert("启动任务失败");
							}
						},
						error : function(data) {
							alert("发生错误");
						}
					});
				});
			}
		});
	}
	function ywhSettings(xqid,name,courtcount,wyCount) {
		$("#ywh_settings_wy_court_id").val(xqid);
		$("#ywhSettings_name").val(name);
		$("#ywh_settings_courtcount").val(courtcount);
		$("#ywh_settings_wyCount").val(wyCount);
		$('#submitYwhWySettings', $courtContainer).attr("url", "xq/update/wyCount");
		$('#ywhSettingsGridDiv', $courtContainer).modal("show");
		createYwhSettingsGrid(xqid);

		$('#ywhSettingsBtn').click(function() {
			if (!$validateCourtForm.checkForm()) {
				$validateCourtForm.defaultShowErrors();
				return;
			}
			var url = $(this).attr("url");
			$.loy.confirm("确定要修改这条记录吗？", function() {
				$.loy.ajax({
					url : url,
					data : $("#ywhSettingsForm", $courtContainer).serialize(),
					success : function(data) {
						$('#ywhSettingsModalDiv', $courtContainer).modal("hide");
						ywhSettingsGrid.jqGrid().trigger("reloadGrid");
					},
					error : function(data) {
						alert("发生错误");
					}
				});
			});
		});
	}
	function createYwhSettingsGrid(xqid) {
		var grid_selector = "#ywh_settings_grid_table";
		var pager_selector = "#ywh_settings_grid_pager";
		var colNames = [ '', '楼栋号', '单元号', '总户数', '成员数', '操作' ];
		$(grid_selector).jqGrid('GridUnload');
		var width = $("#ywh_settings_grid_table").width();
		ywhSettingsGrid = jQuery(grid_selector).loyGrid({
			url: 'ywh/settings/getAll',
			datatype: 'json',
			postData: {'courtId': xqid},
			mtype: 'GET',
			colNames: colNames,
			colModel: [
				{
					name : 'id',
					index : 'id',
					sortable : false,
					width : 15,
					align : "center",
					editable : true,
					hidden : true
				},
				{
					name : 'building',
					index : 'building',
					sortable : false,
					width : 2,
					align : "center",
					editable : true
				},
				{
					name : 'unit',
					index : 'unit',
					sortable : false,
					width : 2,
					align : "center",
					editable : true
				},
				{
					name : 'totalDoors',
					index : 'totalDoors',
					sortable : false,
					width : 2,
					align : "center",
					editable : true
				},
				{
					name : 'countMember',
					index : 'countMember',
					sortable : false,
					width : 2,
					align : "center",
					editable : true
				},
				{
					name : '',
					index : '',
					width : 1,
					sortable : false,
					align : "center",
					formatter : function(
							cellvalue,
							options,
							rowObject) {
						var button = '';
						if (hasPermissionByCode('resource:update')) {
							button += '<div title="'
									+ $.jgrid.nav.edittitle
									+ '" onclick=ywhSettingsEdit("'
									+ rowObject.id
									+ '");  style="float:left;margin-left:21px;" class="ui-pg-div ui-inline-del"  onmouseover="jQuery(this).addClass(\'ui-state-hover\');" onmouseout="jQuery(this).removeClass(\'ui-state-hover\');"  data-original-title="所选记录"><span class="ui-icon ui-icon-pencil"></span></div>';
						}
						return button;
					}
				}
			],
			pager: pager_selector,
			gridComplete: function(){
				$(this).jqGrid('setGridWidth', 525);
			},
			height : 413,
		}).loyGrid('navGrid',
			pager_selector, {
			"baseUrl" : "ywh/settings",
			accessCodePrefix : 'update',
			"addfunc" : function() {
			},
			"excelfunc" : function(){
			},
			view : false,
			add : false,
			edit : false,
			del : false,
			refresh : false,
			excel : false,
		});
		ywhSettingsGrid.jqGrid('setFrozenColumns');
	}
	
	function ywhSettingsEdit(id){
		clearDoorPlateForm();
		$('#ywhSettingsBtn').attr("url", "ywh/settings/update");
		$('#ywhSettingsModalDiv', $courtContainer).modal("show");
		$.loy.ajax({
			url : 'ywh/settings/findOne',
			method : "GET",
			shade : false,
			data : {
				id : id
			},
			success : function(data) {
				var result = data.data;
				$('#ywh_settings_id').val(result.id ? result.id : null)
				$('#ywh_settings_court_id').val(result.courtId ? result.courtId : null);
				$('#ywh_settings_building').val(result.building ? result.building : null);
				$('#ywh_settings_unit').val(result.unit ? result.unit : null);
				$('#ywh_settings_total_doors').val(result.totalDoors ? result.totalDoors : 0);
				$('#ywh_settings_count_member').val(result.countMember ? result.countMember : 1);
			}
		});
	}

	function createDoorplateGrid(xqid){
		var grid_selector2 = "#doorplate_grid-table";
		var pager_selector2 = "#doorplate_grid-pager";
		var colNames = [ '', '门牌号','楼栋号','单元号','楼层号','房号','业主姓名', '操作' ];
		$(grid_selector2).jqGrid('GridUnload');
		doorplateGrid = jQuery(grid_selector2).loyGrid({
			url : 'mp/findDoorplateByxq',
			datatype : "json",
			postData: {"courtId" : xqid},
			mtype : 'GET',
			colNames : colNames,
			colModel : [
				{
					name : 'id',
					index : 'id',
					sortable : false,
					width : 1,
					align : "center",
					editable : true,
					hidden : true
				},
				{
					name : 'doorplateNo',
					index : 'doorplateNo',
					sortable : false,
					width : 2,
					align : "center",
					editable : true
				},
				{
					name : 'building',
					index : 'building',
					sortable : false,
					width : 1,
					align : "center",
					editable : true
				},
				{
					name : 'unit',
					index : 'unit',
					sortable : false,
					width : 1,
					align : "center",
					editable : true
				},
				{
					name : 'floor',
					index : 'floor',
					sortable : false,
					width : 1,
					align : "center",
					editable : true
				},
				{
					name : 'no',
					index : 'no',
					sortable : false,
					width : 1,
					align : "center",
					editable : true
				},
				{
					name : 'proprietorName',
					index : 'proprietorName',
					sortable : false,
					width : 2,
					align : "center",
					editable : true,
					formatter : function(
							cellvalue,
							options,
							rowObject) {
						if(cellvalue==null || cellvalue==""){
							return "暂无业主";
						}else{
							return cellvalue;
						}
					}
				},
				{
					name : '',
					index : '',
					width : 1,
					sortable : false,
					align : "center",
					formatter : function(
							cellvalue,
							options,
							rowObject) {
						var button = '';
						if (hasPermissionByCode('resource:update')) {
							button += '<div title="'
									+ $.jgrid.nav.edittitle
									+ '" onclick=doorplateEdit("'
									+ rowObject.id
									+ '");  style="float:left;margin-left:21px;" class="ui-pg-div ui-inline-del"  onmouseover="jQuery(this).addClass(\'ui-state-hover\');" onmouseout="jQuery(this).removeClass(\'ui-state-hover\');"  data-original-title="所选记录"><span class="ui-icon ui-icon-pencil"></span></div>';
						}
						if (hasPermissionByCode('resource:del')) {
							var del = '<div title="'
									+ $.jgrid.nav.deltitle
									+ '" onclick=doorplateDel("'
									+ rowObject.id
									+ '","'
									+ rowObject.proprietorId
									+'");  style="float:left;margin-left:5px;" class="ui-pg-div ui-inline-del"  onmouseover="jQuery(this).addClass(\'ui-state-hover\');" onmouseout="jQuery(this).removeClass(\'ui-state-hover\');"  data-original-title="所选记录"><span class="ui-icon ace-icon ace-icon fa fa-trash-o red"></span></div>';
							//button += del;
						}
						return button;
					}
				}],
					pager : pager_selector2,
					gridComplete:function(){
			        	$(this).jqGrid('setGridWidth',660);
	                },
					height : '413px',
				}).loyGrid('navGrid',
					pager_selector2, {
					"baseUrl" : "mp/",
					accessCodePrefix : 'addmpInfo',
					"addfunc" : function() {
						doorplateAdd(xqid);
					},
					"excelfunc" : function(){
						$("#courtIdForDoor").val(xqid);
						if(excelDropzone!=null){
							excelDropzone.destroy();
							$("#filePathForDoor").val("");
							$("#fileIdForDoor").val("");
							$("#fileSuffixForDoor").val("");
						}
						initExcelDropZone();
						$("#doorplateExcelModalDiv", $courtContainer).modal("show");
						//$("#excelImport").trigger("click");  
					},
					view : false,
					add : false,
					edit : false,
					del : false,
					refresh : false,
					excel : false,
					//exceltitle :'导入Excel'
				});
		doorplateGrid.jqGrid('setFrozenColumns');
	}
	
	function initExcelDropZone(){
		excelDropzone = new Dropzone("#doorplateExceldropzone",{
			url : "/excel/upload", //必须填写
			method : "post", //也可用put
			paramName : "file", //默认为file 
			headers : $.loy.token(),
			maxFiles : 1,//一次性上传的文件数量上限
			maxFilesize : 10, //MB
			acceptedFiles : ".xls,.xlsx", //上传的类型  
			dictDefaultMessage : "点击或拖拽上传文件",
			dictMaxFilesExceeded : "一次只能上传一个Excel!",
			addRemoveLinks : true,
			clickable : "#excelButton", // 点击某个按钮或区域后出现选择电脑中本地图片，默认是previewsContainer指定的区域
			init : function() {
				MDropzone = this;
				this.on("removedfile",function(file) {
					$("#filePathForDoor").val("");
					$("#fileIdForDoor").val("");
					$("#fileSuffixForDoor").val("");
					if(excelDropzone!=null){
						//excelDropzone.destroy();
						//initExcelDropZone();
					}
				});

				this.on("success",function(file,data) {
					console.log(data);
					if (data.success) {
						if (data.data.error === 0) {
							//上传成功后触发的方法
							$("#filePathForDoor").val(data.data.obj.mediaurl);
							$("#fileIdForDoor").val(data.data.obj.id);
							$("#fileSuffixForDoor").val(data.data.obj.mediasuffix);
							$.loy.alert("文档数据格式验证通过，上传成功！");
						} else {
							$.loy.alert("文档数据格式验证失败：" + data.data.errorMsg);
							$(file.previewElement).find('[data-dz-errormessage]').html(data.data.errorMsg);
						}
					} else {
						$.loy.alert("未知错误");
					}
				});

				this.on("error",function(file,message) {
					$(file.previewElement).find('[data-dz-errormessage]').html(message.data ? message.data.error: message);
				});
			}
		});
	}
	
	function doorplateEdit(doorplateId){
		clearDoorPlateForm();
		$('#submitDoorplateBtn').attr("url", "mp/addmpInfo");
		$('#doorplateModalDiv', $courtContainer).modal("show");
		$.loy.ajax({
			url : 'mp/findOne',
			method : "GET",
			shade : false,
			data : {
				id : doorplateId
			},
			success : function(data) {
				var result = data.data;
				$('#courtId').val(result.courtId ? result.courtId : '');
				$("#doorplateId").val(result.id ? result.id : '');
				$('#doorplateNo').val(result.doorplateNo ? result.doorplateNo : '');
				$('#doorplateUnit').val(result.unit ? result.unit : '');
				$('#doorplateBuilding').val(result.building ? result.building : '');
				$('#floor').val(result.floor ? result.floor : '');
				$('#doorNo').val(result.no ? result.no : '');
			}
		});
	}
	
	function doorplateDel(doorplateId,proprietorId){
		var message="确定要删除这条记录吗？";
		if(null!=proprietorId &&"null"!=proprietorId){
			message="此门派号已经绑定了业主，确定要进行删除吗？";
		}
		var that = this;
		$.loy.confirm(message, function() {
			$.loy.ajax({
				url : 'mp/delmpInfo',
				data : {
					id : doorplateId
				},
				success : function(data) {
					that.refreshDoorplateGrid();
				}
			});
		});
	}
	
	function initCourtDropZone(muban){
		courtDropzone = new Dropzone("#courtdropzone",{
			url : "/sys/img/upload", //必须填写
			method : "post", //也可用put
			paramName : "file", //默认为file 
			headers : $.loy.token(),
			maxFiles : 10,//一次性上传的文件数量上限
			maxFilesize : 20, //MB
			acceptedFiles : ".jpg,.gif,.png", //上传的类型  
			dictDefaultMessage : "",
			dictMaxFilesExceeded : "一次只能上传10张图片!",
			addRemoveLinks : false,
			clickable : "#addCourtButton", // 点击某个按钮或区域后出现选择电脑中本地图片，默认是previewsContainer指定的区域
			previewTemplate : muban,//设置显示模板					    
			init : function() {
				MDropzone = this;
				this.on("removedfile",function(file) {
				});

				this.on("addedfile",function(file) {
					//上传文件时触发的事件
					file.previewElement.querySelector('[data-rel]').setAttribute('id',file.id);
					file.previewElement.querySelector('[data-rel]').setAttribute('href',file.httpurl);
				});

				this.on("queuecomplete",function() {
					$('.dropzone [data-rel="colorbox"]').colorbox(colorbox_params);
				});

				this.on("success",function(file,data) {
					//上传完成后触发的方法	    
					file.previewElement.querySelector('[data-rel]').setAttribute('id',data.data.obj.id);
					file.previewElement.querySelector('[data-rel]').setAttribute('href',data.data.obj.httpurl);
				});
				this.on("error",function(file,message) {
					$(file.previewElement).find('[data-dz-errormessage]').html(message.data ? message.data.error: message);
				});
			}
		});
	}
</script>